package com.shrct.businessprocess.budget.impl;

import com.shrct.businessprocess.budget.RCHasCostBudget;
import com.shrct.businessprocess.budget.RCHasCostBudgetPayProcess;
import com.shrct.businessprocess.budget.RCHasCostBudgetPayRequest;
import com.shrct.businessprocess.budget.impl.RCHasCostBudgetCostRequestImpl;
import com.shrct.businessprocess.budget.proxy.RCHasCostBudgetPayRequestProxy;
import edu.fudan.langlab.domain.workflow.BusinessProcess;
import edu.fudan.mylang.pf.IGenericQuery;
import edu.fudan.mylang.pf.IObjectFactory;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;

@Entity
@DiscriminatorValue("RCHASCOSTBUDGETPAYREQUEST_TYPE")
public class RCHasCostBudgetPayRequestImpl extends RCHasCostBudgetCostRequestImpl implements RCHasCostBudgetPayRequest {
  public RCHasCostBudgetPayRequestImpl() {
    super();
  }
  
  public RCHasCostBudgetPayRequestImpl(final RCHasCostBudget budget) {
    super( budget);
    
  }
  
  public BusinessProcess getProcess() {
    IGenericQuery<RCHasCostBudgetPayProcess> query=getObjectFactory().createGenericQuery(RCHasCostBudgetPayProcess.class,"select e from com.shrct.businessprocess.budget.impl.RCHasCostBudgetPayProcessImpl as e   where ((e.payRequest) = (:this)) and  e.active = 1      ").setParameter("this",this);
    RCHasCostBudgetPayProcess _uniqueResult = query.uniqueResult();
    return ((BusinessProcess) _uniqueResult);
  }
  
  public static RCHasCostBudgetPayRequest create(final RCHasCostBudget budget, final IObjectFactory objectFactory) {
    com.shrct.businessprocess.budget.RCHasCostBudgetPayRequest rCHasCostBudgetPayRequest = new com.shrct.businessprocess.budget.impl.RCHasCostBudgetPayRequestImpl(
    	budget
    );
    objectFactory.create(rCHasCostBudgetPayRequest);
    return rCHasCostBudgetPayRequest;			
    
  }
  
  public static RCHasCostBudgetPayRequest createRCHasCostBudgetPayRequestImpl(final RCHasCostBudget budget, final IObjectFactory objectFactory, final Procedure1<RCHasCostBudgetPayRequest> init) {
    com.shrct.businessprocess.budget.RCHasCostBudgetPayRequest rCHasCostBudgetPayRequest = new com.shrct.businessprocess.budget.impl.RCHasCostBudgetPayRequestImpl(
    	budget
    );
    objectFactory.create(rCHasCostBudgetPayRequest);
    init.apply(rCHasCostBudgetPayRequest);
    
    return rCHasCostBudgetPayRequest;			
    
  }
  
  public RCHasCostBudgetPayRequestProxy toProxy() {
    com.shrct.businessprocess.budget.proxy.RCHasCostBudgetPayRequestProxy proxy = new com.shrct.businessprocess.budget.proxy.RCHasCostBudgetPayRequestProxy();
    proxy.setId(this.getId());
    if(this instanceof edu.fudan.mylang.pf.INamedModelObject){
    	proxy.setName(((edu.fudan.mylang.pf.INamedModelObject)this).getEntityName());
    }
    return proxy;
    
  }
}
